package com.itany.corejava.code09_集合.set集合;

import com.itany.corejava.code08_常用类.包装类.Stu;

import java.util.HashSet;
import java.util.Set;

/**
 * @author MissChen
 * @version 1.0
 * @date 2023 年11月21日 11:31
 */
public class Test02_判断元素是否重复 {
    public static void main(String[] args) {
        Set<Student> students = new HashSet<>();
        Student stu1 = new Student(1, "alice");
        Student stu2 = new Student(1, "alice");
        Student stu3 = new Student(1, "alice");
        students.add(stu1);
        students.add(stu2);
        students.add(stu3);
        // System.out.println(stu1.equals(stu2));//true,重写了equals方法和hashcode方法
        System.out.println(students);
    }
}
